<?php
class menuController extends adminController{

	public function index(){
		$list=ApiHook('hook_menu_index');
		$list=model('menu')->sort_menu($list);
		echo model('menu')->to_html($list,'管理首页');
		ApiHook('hook_menu_index_ext');
	}
	
	public function category(){
		$list=ApiHook('hook_menu_category');
		$list=model('menu')->sort_menu($list);
		echo model('menu')->to_html($list,'栏目管理');
		ApiHook('hook_menu_category_ext');
	}

	public function content(){
		$info=$this->getLogin();
		$user_group=api('admin_user','group_info',$info['gid']);
		$form_purview=unserialize($user_group['form_purview']);
		$model_purview=unserialize($user_group['model_purview']);

		$model_list=model('model_manage')->model_list();
		if(!empty($model_list)){
			foreach ($model_list as $value) {
				if(!in_array($value['model'], (array)$model_purview)&&!$user_group['keep']){
					continue;
				}
				if($value['list_type']){
					$list[$value['name'].'管理'] = array('url'=>url($value['model'].'/admin_content/index'),'sequence'=>0);
				}
			}
		}

		$new_list=ApiHook('hook_menu_content');
		$new_list=model('menu')->sort_menu($new_list);
		$list=array_merge((array)$list,(array)$new_list);
		echo model('menu')->to_html($list,'内容管理');

		$form_list=api('form','form_list');
		$list2=array();
		if(!empty($form_list)){
			foreach ($form_list as $value) {
				if(!in_array($value['table'], (array)$form_purview)&&!$user_group['keep']){
					continue;
				}
				$list2[$value['name']]=array('url'=>url('form/admin_list_content/index',array('fid'=>$value['id'])));
			}
		}
		echo model('menu')->to_html($list2,'表单内容',false);
		ApiHook('hook_menu_content_ext');
	}

	public function expand(){
		$list=ApiHook('hook_menu_expand');
		$list=model('menu')->sort_menu($list);
		echo model('menu')->to_html($list,'扩展功能');
		ApiHook('hook_menu_expand_ext');
	}

	public function admin(){
		$list=ApiHook('hook_menu_admin');
		$list=model('menu')->sort_menu($list);
		echo model('menu')->to_html($list,'后台用户');
		$list=ApiHook('hook_menu_system');
		$list=model('menu')->sort_menu($list);
		echo model('menu')->to_html($list,'系统管理',false);
		ApiHook('hook_menu_admin_ext');
	}

	
}